﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WikiCsharpCommon.Settings;

namespace WikiCsharpCommon
{
    public partial class Validating : Common.Forms.Validating
    {
        private MyBugtracker m_mbt = null;
        private MySettingsControl control_ = null;

        public Validating(String parameters, Common.Controls.SettingsControl control)
            : base()
        {
            control_ = control as MySettingsControl;
            m_mbt = new MyBugtracker(new Settings.MySettingsManager(parameters));
        }

        protected override void Validating_Shown(object sender, EventArgs e)
        {
            Common.ProgressCallback siid = new Common.ProgressCallback(UpdateProgress);
            Common.TestCallback tsc = new Common.TestCallback(TestSuccess);
            Common.TestCallback tfc = new Common.TestCallback(TestFail);

            m_mbt.RegisterProgressCallback(siid);
            m_mbt.RegisterTestCallback(tsc, tfc);

            base.Validating_Shown(sender, e);
        }
        
        protected override void StartTest()
        {
            if (m_mbt.ValidateSettings())
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                this.DialogResult = DialogResult.None;
            }
        }
    }
}
